-
-
Notifications
You must be signed in to change notification settings - Fork 357
WIP feat: rslib executor #3784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
WIP feat: rslib executor #3784
Conversation
❌ Deploy Preview for module-federation-docs failed. Why did it fail? →
|
|
Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: Claude <[email protected]>
const args = ['rslib', 'build']; | ||
|
||
if (options.configFile && options.configFile !== 'rslib.config.ts') { | ||
args.push('--config', options.configFile); |
Check warning
Code scanning / CodeQL
Unsafe shell command constructed from library input Medium
library input
shell command
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 23 days ago
To fix the issue, we should replace the unsafe exec
function with the safer execFile
function from the child_process
module. Instead of constructing a single string command, we should pass the command and arguments as separate array elements to execFile
. This approach avoids shell interpretation and mitigates the risk of command injection.
Specifically:
- Replace the
args.join(' ')
logic with a direct call toexecFile
, passing theargs
array (split into the command and its arguments). - Remove the need for
command
as a single string. - Update the
promisify(exec)
call topromisify(execFile)
.
-
Copy modified line R2 -
Copy modified line R48 -
Copy modified line R51
@@ -1,5 +1,5 @@ | ||
import type { ExecutorContext } from '@nx/devkit'; | ||
import { exec } from 'child_process'; | ||
import { execFile } from 'child_process'; | ||
import { promisify } from 'util'; | ||
import { join } from 'path'; | ||
|
||
@@ -44,13 +44,11 @@ | ||
// Note: --mode option not supported in current rslib version | ||
// Environment will be set via NODE_ENV instead | ||
|
||
const command = args.join(' '); | ||
|
||
try { | ||
console.info(`Running: ${command}`); | ||
console.info(`Running: ${args.join(' ')}`); | ||
console.info(`Working directory: ${join(context.root, projectRoot)}`); | ||
|
||
const { stdout, stderr } = await promisify(exec)(command, { | ||
const { stdout, stderr } = await promisify(execFile)(args[0], args.slice(1), { | ||
cwd: join(context.root, projectRoot), | ||
env: { | ||
...process.env, |
Description
This PR introduces a new Rslib Nx Plugin that provides executors for building and developing with Rslib, a framework-agnostic library building solution from the Rsbuild ecosystem.
Key Features
rslib:build
): Builds libraries using Rslib with support for multiple formats (ESM, CJS, UMD)rslib:dev
): Runs Rslib in development mode with hot reloading and Module Federation supportrslib:echo
): Simple testing executor for plugin validationWhat's Included
1. Rslib Nx Plugin (
tools/rslib-plugin/
)2. Runtime Core Updates (
packages/runtime-core/
)rslib.config.ts
configuration3. Example Implementation (
apps/rslib-module/
)Benefits
Usage Example
This integration brings modern library building capabilities to the Module Federation ecosystem while maintaining compatibility with existing Nx workflows.
Related Issue
Addresses the need for a modern, efficient library building solution within the Module Federation ecosystem that supports both traditional library builds and Module Federation development workflows.
Types of changes
Checklist